#include <stdio.h>

#define LEN 10

int input (int arr[]);
void output(int arr[]);
void ave(int arr[]);
void max(int arr[]);
void min(int arr[]);
void find(int arr[]);
void queue(int arr[]);

int main(void) {
	int array[10] = { 0 };
	
	input(array);
	output(array);
	ave(array);
	max(array);
	min(array);
	find(array);
	queue(array);
//	output(array);
	
	return 0;
}


/*input*/
int input(int arr[]) {
	int i = 0;
	printf("Please input 10 numbers:\n");
	for (i = 0; i < 10; i++) {
		scanf("%d", &arr[i]);
	}
	printf("Input Complete！\n\n");
}

/*output*/
void output(int arr[]) {
	int i = 0;
	printf("Numbers in this array are:\t");
	for (i = 0; i < LEN; i++) {
		printf("%d\t", arr[i]);
	}
	printf("\n\n");
}

/*average*/
void ave(int arr[]) {
	int i = 0, sum = 0;
	double ave = 0;
	for (i = 0; i < LEN; i++) {
		sum += arr[i];
	}
	ave = (1.0) * sum / LEN;
	printf("Average is %lf.\n\n", ave);
}

/*max*/
void max(int arr[]) {
	int i = 0,  max = arr[0];
	for (i = 0; i < LEN; i++) {
		if (arr[i] > max) {
			max = arr[i];
		}
	}
	printf("The max number is %d.\n\n", max);
}

/*min*/
void min(int arr[]) {
	int i = 0, min = arr[0];
	for (i = 0; i < LEN; i++) {
		if (arr[i] < min) {
			min = arr[i];
		}
	}
	printf("The min number is %d.\n\n", min);
}

/*search*/
void find(int arr[]) {
	int i = 0, find = 0, num = 0;
	printf("Please input a number to see whether it's in this array:\n");
	scanf("%d", &num);
	for (i = 0; i < LEN; i++) {
		if (arr[i] == num) {
			find = 1;
			printf("Success<^v^>    It's the %dth number.\n", i);
		}
	}

	if (find == 0) {
		printf("Failure\n");
	} 
	printf("\n");
}

/*queue*/
void queue(int arr[]) {
	int i = 0, j = 0, tmp = 0;
	printf("Let's queue!\n\n");
	for (i = 0; i < LEN; i++ ) {
		for (j = 0; j < (LEN - i - 1); j++) {
			if (arr[j] > arr[j + 1]) {
				tmp = arr[j];
				arr[j] = arr[j + 1];
				arr[j + 1] = tmp;
			}
		}
	}
}